<%@ page language="java" pageEncoding="UTF-8"%>

<style type="text/css">
#map_canvas {
	width: 700px;
	height: 500px;
}
</style>

<div id="map_canvas"></div>
<div class="well hide" id="mapNotLoadDiv"></div>

<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=tmKLDQePokgC7m0EyDmIYFal"></script>
<script type="text/javascript">
function initMap(){
	if(task.status != "completed"){
		$("#map_canvas").hide();
		$("#mapNotLoadDiv").show();
		$("#mapNotLoadDiv").text("此考勤暂未定位，无法查看现场地图。");
		return;
	}

	if(!hasLocation(task)){
		$("#map_canvas").hide();
		$("#mapNotLoadDiv").show();
		$("#mapNotLoadDiv").text("此考勤未定位，无法查看现场地图。");
		return;
	}

	//$("map_canvas").show();
	var map = new BMap.Map("map_canvas");
	var pt = new BMap.Point(task.longitude, task.latitude);
	map.centerAndZoom(pt, 12); 
	map.enableScrollWheelZoom();    //启用滚轮放大缩小
	map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_BOTTOM_RIGHT, type: BMAP_NAVIGATION_CONTROL_ZOOM}));  //右下角，仅包含缩放按钮
	var myIcon = new BMap.Icon(ctx + "/images/map/pin-blue.png", new BMap.Size(32,32));
	var marker2 = new BMap.Marker(pt,{icon:myIcon});  // 创建标注
	map.addOverlay(marker2);              // 将标注添加到地图中

	//（创建信息窗口）
	var infoWindow2 = new BMap.InfoWindow(createMarker());
	marker2.addEventListener("click", function(){this.openInfoWindow(infoWindow2);});
	map.openInfoWindow(infoWindow2,pt); //开启信息窗口
}

function createMarker() {
	var html = "<p><strong>" + task.execPersonName + " " + getCheckinType(task.type) + " " + task.locateDate + "</strong></p>";
	html = html + "<p>经度:" + task.longitude + ", 纬度:" + task.latitude + "</p>";
	html = html + "<p>" + task.locationAddress + "</p>";
	return html;
}

</script>
